//生产工艺及设备设施api
//导入request.js工具
import request from "@/utils/request";
//调用注册接口的函数

//工艺流程接口
//添加
export const saveFlow = ({ name, flowDesc }) => {
  console.log(name, flowDesc);
  return request.post("/process-flow", {}, {
    params: {
      name,
      desc: flowDesc
    }
  });
};
//分页查询
export const queryFlows = (pageNo, pageSize) => {
  return request.get("/process-flow/page", {
    params: {
      pageNo,
      pageSize,
    },
  });
};
//根据id/name查询工艺流程
export const select = (name) => {
  return request.get("/process-flow", {
    params: {
      name
    }
  });
};
//批量删除工艺流程
export const deleteBatch = (ids) => {
  ids = ids.join(',');
  return request.delete(`/process-flow/ids?ids=${ids}`);
};
//修改工艺流程
export const update = (form) => {
  return request.put("/process-flow", form);
};
//--------------------------------------------------------
//流程清单接口

//添加
export const listSaveFlow = (form) => {
  return request.post("/process-list", form);
};
//分页查询 
export const listQueryFlows = (pageNo, pageSize, flowId, type) => {
  return request.get("/process-list/page", {
    params: {
      pageNo,
      pageSize,
      flowId,
      type
    },
  });
};
//根据id查询流程清单 process-list
export const listSelect = (name, flowId) => {
  return request.get("/process-list", {
    params: {
      name,
      flowId
    }
  });
};
// 修改流程清单 /process-list
export const listUpdate = (form) => {
  return request.put("/process-list", form);
};
// 批量删除流程清单  /process-list/ids
export const listDeleteBatch = (ids) => {
  ids = ids.join(',');
  return request.delete(`/process-list/ids?ids=${ids}`);
};
//--------------------------------------------------------
//设备信息相关接口

//添加
export const saveEquipment = (form) => {
  return request.post("/equipment", form);
};
//分页查询 
export const queryEquipments = (pageNo, pageSize, listId) => {
  return request.get("/equipment/page", {
    params: {
      pageNo,
      pageSize,
      listId
    },
  });
};
//根据id查询设备信息 equipment
export const queryEquipment = (name, listId) => {
  return request.get("/equipment", {
    params: {
      name,
      listId
    }
  });
};
// 修改设备信息 /equipment
export const updateEquipment = (form) => {
  return request.put("/equipment", form);
};
// 批量删除设备信息  /equipment/ids
export const deleteEquipment = (ids) => {
  ids = ids.join(',');
  return request.delete(`/equipment/ids?ids=${ids}`);
};

//--------------------------------------------------------
//维护保养记录相关接口
//添加
export const saveRecord = (form) => {
  return request.post("/maintenance-record", form);
};
//分页查询 
export const queryRecords = (pageNo, pageSize, equipmentId) => {
  return request.get("/maintenance-record/page", {
    params: {
      pageNo,
      pageSize,
      equipmentId
    },
  });
};
//根据id查询维护保养记录 maintenance-record
export const queryRecord = (name, equipmentId) => {
  return request.get("/maintenance-record", {
    params: {
      name,
      equipmentId
    }
  });
};
// 修改维护保养记录 /maintenance-record
export const updateRecord = (form) => {
  return request.put("/maintenance-record", form);
};
// 批量删除维护保养记录  /maintenance-record/ids
export const deleteRecord = (ids) => {
  ids = ids.join(',');
  return request.delete(`/maintenance-record/ids?ids=${ids}`);
};




//--------------------------------------------------------
//维护记录详细表
//添加
export const saveDetail = (form) => {
  return request.post("/maintenance-detail", form);
};
//分页查询 
export const queryDetails = (pageNo, pageSize, recordId) => {
  return request.get("/maintenance-detail/page", {
    params: {
      pageNo,
      pageSize,
      recordId
    },
  });
};
//根据id查询维护保养记录 maintenance-detail
export const queryDetail = (name, recordId) => {
  return request.get("/maintenance-detail", {
    params: {
      name,
      recordId
    }
  });
};
// 修改维护保养记录 /maintenance-detail
export const updateDetail = (form) => {
  return request.put("/maintenance-detail", form);
};
// 批量删除维护保养记录  /maintenance-detail/ids
export const deleteDetail = (ids) => {
  ids = ids.join(',');
  return request.delete(`/maintenance-detail/ids?ids=${ids}`);
};

//--------------------------------------------------------
//安全设施检查相关接口
//添加
export const saveSafetyCheck = (form) => {
  console.log("aaa");
  console.log(form);
  return request.post("/safety-checklist", form);
};
//分页查询 
export const querySafetyChecks = (pageNo, pageSize, listId) => {
  return request.get("/safety-checklist/page", {
    params: {
      pageNo,
      pageSize,
      listId
    },
  });
};
//根据id查询维护保养记录 safety-checklist
export const querySafetyCheck = (name, listId) => {
  return request.get("/safety-checklist", {
    params: {
      name,
      listId
    }
  });
};
// 修改维护保养记录 /safety-checklist
export const updateSafetyCheck = (form) => {
  return request.put("/safety-checklist", form);
};
// 批量删除维护保养记录  /safety-checklist/ids
export const deleteSafetyCheck = (ids) => {
  ids = ids.join(',');
  return request.delete(`/safety-checklist/ids?ids=${ids}`);
};

